<template>
	<view>
		<view class="InfoBOX">
			<view class="Title">请设置您的支付密码</view>
			<view class="linhe"><text class="red">*</text>设置新密码</view>
			<view class="Code">
				<input  type="password" maxlength="6" v-model="password" placeholder="6位数字组成"/>
			</view>
			<view class="linhe"><text class="red">*</text>确认新密码</view>
			<view class="Code">
				<input  type="password" maxlength="6" v-model="confirm_password" placeholder="请再次输入您设置的密码"/>
			</view>
			<view class="Next" @click="Submission">
				提交
			</view>
		</view>
		
	</view>
</template>

<script>
	const msdjs = require('@/common/api_sign/md5.js');
	export default {
		data() {
			return {
				password:"",
				confirm_password:"",
				auth_modify_paypwd:"",
				pay_sn:""
			}
		},
		created() {
		},
		onLoad(e) {
			console.log(e,132154)
			if(e.pay_sn){
			this.pay_sn=e.pay_sn;
			}
		},
		methods: {
			Submission(){
				let reg=/^\d{6}$/;
				let that = this;
				if(!that.password || !that.confirm_password){
					uni.showToast({
						icon:"none",
						title:"请输入新密码"
					})
				}else if(that.password != that.confirm_password){
					uni.showToast({
						icon:"none",
						title:"两次输入密码不一致"
					})
				}else{
					if(!reg.test(that.password)){
						uni.showToast({
							icon:"none",
							title:"密码格式错误"
						})
					}else{
						this.$util.request({
							url: '/mobile/index.php?act=member_security&op=modify_paypwd',
							method: 'POST',
							data: {
								auth_modify_paypwd:that.auth_modify_paypwd,
								password:msdjs.hexMD5(that.password),
								confirm_password:msdjs.hexMD5(that.confirm_password)
							},
						}).then(function(res) {
							console.log(res)
							if(res.error_code==0){
								uni.showToast({
									title:"保存成功",
									success() {
										
										setTimeout(()=>{
											if(that.pay_sn){
												
												uni.navigateTo({
													url:"/plug/pay/cashier?pay_sn="+that.pay_sn
												})
											}else{
												uni.switchTab({
													url:"/main/member/index"
												})
											}
											
										},1000)
									}
								})
							}else{
								uni.showToast({
									title:res.message,
									icon:"none"
								})
							}
						
						})
					}
					
				}
				
			}
		},
		onLoad(e){
			this.auth_modify_paypwd=e.auth_modify_paypwd
		},
		
	}
</script>

<style>
	.red{
		color: red;
	}
	.InfoBOX{
		margin: 20rpx;
		padding: 15rpx 40rpx;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		}
	.Title{
		font-size: 32rpx;
		text-align: center;
	}
	.linhe{
		line-height: 70rpx;
	}
	.Code{
		width: 100%;
		height: 70rpx;
		border: 1rpx solid #eee;
		margin: 10rpx 0;
	}
	.Code input{
		height: 70rpx;
		margin-left: 15rpx;
		font-size: 28rpx;
	}
	.Next{
		background-color: #ff4300;
		color: #FFFFFF;
		font-size: 30rpx;
		line-height: 70rpx;
		margin: 25rpx 0;
		text-align: center;
	}
</style>
